package com.claimSettlement.controller;

import com.claimSettlement.pojo.Recognizee;
import com.claimSettlement.service.RecognizeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 被保人信息控制层
 * 曹文韬 -- 2021-05-19
 */
@RestController
@RequestMapping("/recognizee")
public class RecognizeeController {
    @Resource
    private RecognizeeService recognizeeService;

    @RequestMapping("/getRecognizeeAll")
    public PageInfo<Recognizee> getRecognizeeAll(int page){
        PageHelper.startPage(page,4);
        List<Recognizee> list = recognizeeService.getRecognizeeAll();
        PageInfo<Recognizee> pageInfo = new PageInfo<Recognizee>(list);
        return pageInfo;
    }

    @RequestMapping("/getRecognizeeByNameOrCredentialsId")
    public PageInfo<Recognizee> getRecognizeeByNameOrCredentialsId(String name,String credentialsId,int page){
        PageHelper.startPage(page,4);
        List<Recognizee> list = recognizeeService.getRecognizeeByNameOrCredentialsId(name, credentialsId);
        PageInfo<Recognizee> pageInfo = new PageInfo<Recognizee>(list);
        return pageInfo;
    }

    @RequestMapping("/getRecognizeeById")
    public Recognizee getRecognizeeById(int recognizeeId){
        return recognizeeService.getRecognizeeById(recognizeeId);
    }

    @RequestMapping(value = "/insRecognizee", method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String insRecognizee(@RequestBody Recognizee recognizee){
        return recognizeeService.insRecognizee(recognizee) > 0 ? "成功":"失败";
    }

    @RequestMapping(value = "/updRecognizee", method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String updRecognizee(@RequestBody Recognizee recognizee){
        return recognizeeService.updRecognizee(recognizee) > 0 ? "成功":"失败";
    }

    @RequestMapping(value = "/delRecognizee",produces = "text/html;charset=UTF-8")
    public String delRecognizee(int recognizeeId){
        return recognizeeService.delRecognizee(recognizeeId) > 0 ? "成功":"失败";
    }
    @RequestMapping(value = "/getRecognizeePid")
    public List<Recognizee> getRecognizeePid() {
        return recognizeeService.getRecognizeePid();
    }
}
